package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.domain.Delivery;
import com.example.mapper.DeliveryMapper;
import com.example.service.IDeliveryService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> implements IDeliveryService {

    @Override
    public boolean createDelivery(Delivery delivery) {
        return save(delivery);
    }

    @Override
    public boolean updateDelivery(Delivery delivery) {
        return updateById(delivery);
    }

    @Override
    public boolean deleteDeliveryById(int id) {
        return removeById(id);
    }

    @Override
    public Delivery getDeliveryById(int id) {
        return getById(id);
    }

    @Override
    public List<Delivery> getDeliveriesByUid(int uid) {
        QueryWrapper<Delivery> wrapper = new QueryWrapper<>();
        wrapper.eq("uid", uid);
        return list(wrapper);
    }

}